//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>

#include "PatternsCathFASTAProfile.h"
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
using namespace std;
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
int main (int argc, char** argv) {
  
  String* filenamePatternsCompact        = NULL;
  String* filenameCathFASTAProfile       = NULL;
  String* filenameLigandCathFASTAProfile = NULL;
  String* filenameOut                    = NULL;
  String* category                       = NULL;
  
  if (argc < 5) {
    
    cout << "Error in the input parameters! Must by like: " << endl;
    cout << "./ComputeProbabilityOfPatternIdentifyBS <Filename In with compact Patterns>";
    cout <<                                        " <Filename CATH FASTA Profile Complete>";
    cout <<                                        " <Filename CATH FASTA Profile Of Sequences in which the Patterns is extracted>";
    cout <<                                        " <Filename Out with compact Patterns (Updated)>";
    cout <<                                        " <Category - AA, SS, CH, PH, MT>";
    cout << endl;
    
    return 0;
    
  }
  else {
    
    filenamePatternsCompact        = new String(argv[1]);
    filenameCathFASTAProfile       = new String(argv[2]);
    filenameLigandCathFASTAProfile = new String(argv[3]);
    filenameOut                    = new String(argv[4]);
    category                       = new String(argv[5]);
    
    cout << "----------------------------------------------------------------------------------------------------------------" << endl;
    cout << "                                           Filename In with compact Patterns : " << argv[1] << endl;
    cout << "                                        Filename CATH FASTA Profile Complete : " << argv[2] << endl;
    cout << " Filename CATH FASTA Profile Of Sequences in which the Patterns is extracted : " << argv[3] << endl;
    cout << "                                Filename Out with compact Patterns (Updated) : " << argv[4] << endl;
    cout << "                                               Category - AA, SS, CH, PH, MT : " << argv[5] << endl;
    cout << "----------------------------------------------------------------------------------------------------------------" << endl;
    
  }
  
  PatternsCathFASTAProfile* patternsCathFASTAProfile = new PatternsCathFASTAProfile ();
  
  cout << "Preparing the files..." << endl;
  patternsCathFASTAProfile->FilenamePatternsCompact(filenamePatternsCompact);
  patternsCathFASTAProfile->FilenameOut(filenameOut);
  patternsCathFASTAProfile->PrattPatterns()->NamefileOut(filenameOut);
  
  patternsCathFASTAProfile->FilenameCathFASTAProfile(filenameCathFASTAProfile);
  patternsCathFASTAProfile->FilenameLigandCathFASTAProfile(filenameLigandCathFASTAProfile);
  
  cout << "Loading the data..." << endl;
  patternsCathFASTAProfile->LoadData();
  
  cout << "Computing for each pattern the probability of identify the group of domain that bind the same ligand knowing that contain a pattern (True Positive)" << endl;
  patternsCathFASTAProfile->ComputeProbPatternBelongToRightGroup(category);
  
  cout << "Writing the result in the output file..." << endl;
  patternsCathFASTAProfile->PrattPatterns()->CreateCompactPatternFile();
  
  cout << "Finished..." << endl << "Good Bye" << endl;
  
  if (patternsCathFASTAProfile)       delete patternsCathFASTAProfile;
  
  if (filenamePatternsCompact)        delete filenamePatternsCompact;
  if (filenameCathFASTAProfile)       delete filenameCathFASTAProfile;
  if (filenameLigandCathFASTAProfile) delete filenameLigandCathFASTAProfile;
  if (filenameOut)                    delete filenameOut;
  if (category)                       delete category;

  return EXIT_SUCCESS;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//

